package app;

import java.io.*;

public class Test {
	public static void main(String[] args) {
		String path = "D:\\JAFFE\\s";
		String suffix = ".bmp";
		for (int i = 1; i <= 10; i++) {
			String pathTemp = path + i + "\\";
			File tempFile = new File(path + i);
			int tempLength = tempFile.listFiles().length;
			for (int j = tempLength; j >= 1; j--) {
				rename(pathTemp + j + suffix, "" + (j + 1), suffix);
			}
			rename(pathTemp + (tempLength + 1) + suffix, "1", suffix);
		}
		// for (int i = 1; i <= 15; i++) {
		// for (int j = 1; j <= 11; j++) {
		// int t1 = (i - 1) * 11 + j;
		// int t2 = (i - 1) * 11 + (j + 1) % 11 + 1;
		// rename(path + t1 + suffix, "s" + t2, suffix);
		// }
		// }
	}

	public static boolean rename(String AbsolutePath, String newName,
			String Suffix) {
		File file = new File(AbsolutePath);
		if (!file.exists()) {
			System.out.println(AbsolutePath + " doesn't exist!");
			return false;
		}
		String filename = file.getAbsolutePath();
		if (filename.indexOf(".") >= 0) {
			filename = filename.substring(0, filename.lastIndexOf("\\") + 1);
			filename += newName;
		}
		if (!file.renameTo(new File(filename + Suffix))) {
			System.out.println(AbsolutePath + " fails to rename!");
			return false;
		}
		return true;
	}
}
